package com.library.controllers;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.bind.annotation.ActionMapping;

import com.library.slayer.service.LMSBookLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.ParamUtil;

@Controller(value = "DeleteBookController")  
@RequestMapping("VIEW")
public class DeleteBookController {
	@ActionMapping(params = "action=deleteBook")
    public void deleteBook(ActionRequest actionRequest,ActionResponse actionResponse) throws IOException, SystemException, PortalException{
	 long bookId = ParamUtil.getLong(actionRequest, "bookId");
	 
	 if (bookId > 0L) {
		 LMSBookLocalServiceUtil.deleteLMSBook(bookId);
	 
		 String redirectURL = ParamUtil.getString(actionRequest, "redirectURL");
			actionResponse.sendRedirect(redirectURL);
	 }
 }
}
